﻿using DataController;
using System;
using System.Windows.Forms;
using ZdjDataModel;

namespace JGUserLogin
{
    public partial class FormUserLogin : Form
    {
        private UserController userController;
        private LoginModel loginModel = null;
        public FormUserLogin()
        {
            InitializeComponent();
            userController = new UserController();
            loginModel = new LoginModel();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string result = userController.login(loginModel);
            if (!string.IsNullOrEmpty(result))
            {
                lblMsg.Text = result;
                return;
            }
            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void txtUserName_TextChanged(object sender, EventArgs e)
        {
            TextBox textBox = sender as TextBox;
            if (textBox == null)
            {
                return;
            }

            loginModel.UserName = textBox.Text.Trim();
        }

        private void txtPassword_TextChanged(object sender, EventArgs e)
        {
            TextBox textBox = sender as TextBox;
            if (textBox == null)
            {
                return;
            }

            loginModel.Password = textBox.Text.Trim();
        }

        private void cmbRemember_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void btnTest_Click(object sender, EventArgs e)
        {

        }


    }
}
